package com.note.servlet.type;

import com.note.pojo.Notetype;
import com.note.service.note.noteService;
import com.note.service.note.noteServiceImpl;
import lombok.SneakyThrows;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

public class getTypeList extends HttpServlet {
    @SneakyThrows
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String index = req.getParameter("index");
        noteService getTypeList = new noteServiceImpl();
        List<Notetype> typeList = getTypeList.getTypeList();
        req.setAttribute("typelist", typeList);
        if(index.equals("1"))
            req.getRequestDispatcher("/jsp/writeNote.jsp").forward(req,resp);
        else if(index.equals("2"))
            req.getRequestDispatcher("/jsp/typeManage.jsp").forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
